package com.wlzg.collectiontool.db

import androidx.room.*
import com.wlzg.collectiontool.model.bean.*

@Dao
interface UserDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertUser(user: Muser):Long
    @Query("SELECT pwd FROM muser where account=:account")
    suspend fun queypwd(account: String): String?


    @Query("SELECT * FROM PsJin where manholecode=:code")
    suspend fun quePsjinbyCode(code: String): PsJin
    @Query("SELECT * FROM PsYushuikou where combcode=:code")
    suspend fun queyskbyCode(code: String): Psyushuikou
    @Query("SELECT * FROM PsYushuikou where glgcId=:gcid")
    suspend fun queyskbygcid(gcid: Long): Psyushuikou


    @Query("SELECT * FROM Pspfk where outfallcode=:code")
    suspend fun quePspfkbyCode(code: String): Pspfk
    @Query("SELECT * FROM psliguan where risercode=:code")
    suspend fun quelgbyCode(code: String): PsLiguan
    @Query("SELECT * FROM pshfc where septictacode=:code")
    suspend fun quehfcbyCode(code: String): PsHuafenchi



    @Delete
    suspend fun deletejcj(vararg jin:PsJin): Int
    @Delete
    suspend fun deleteysk(vararg ysk:Psyushuikou): Int
    @Delete
    suspend fun deletepfk(vararg pfk:Pspfk): Int
    @Delete
    suspend fun deletelg(vararg lg:PsLiguan): Int
    @Delete
    suspend fun deletehfc(vararg hfc:PsHuafenchi): Int


    @Query("SELECT * FROM PsJin where jinId=:objId")
    suspend fun getPsjin(objId: Long): PsJin

    @Query("SELECT * FROM PsJin where glgcId=:gcid")
    suspend fun getPsjinbygcid(gcid: Long): PsJin

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPsjin(psJin: PsJin):Long

    @Query("SELECT * FROM PsYushuikou where yskId=:objId")
    suspend fun getPsysk(objId: Long): Psyushuikou

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPsysk(psyushuikou: Psyushuikou):Long

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPsk(pspfk: Pspfk):Long

    @Query("SELECT * FROM Pspfk where pfkid=:objId")
    suspend fun getPfk(objId: Long): Pspfk
    @Query("SELECT * FROM Pspfk where glgcId=:gcid")
    suspend fun getPfkbygcid(gcid: Long): Pspfk

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertLg(liguan: PsLiguan):Long

    @Query("SELECT * FROM psliguan where lgid=:objId")
    suspend fun getLg(objId: Long): PsLiguan
    @Query("SELECT * FROM psliguan where glgcId=:gcid")
    suspend fun getLgbygcid(gcid: Long): PsLiguan


    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun inserthfc(huafenchi: PsHuafenchi):Long

    @Query("SELECT * FROM pshfc where hfcId=:objId")
    suspend fun gethfc(objId: Long): PsHuafenchi


    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertgx(gx: PsGuanxian):Long

    @Query("SELECT * FROM psguanxian where gxId=:objId")
    suspend fun getgx(objId: Long): PsGuanxian
    @Query("SELECT * FROM psguanxian where glgcId=:gcId")
    suspend fun getgxBygcid(gcId: Long): PsGuanxian
    @Delete
    suspend fun deleteGx(vararg gx:PsGuanxian): Int



    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPsXiangmu(psXiangmu: PsXiangmu):Long
    @Update
    suspend fun updatePsXiangmu(psXiangmu: PsXiangmu)

    @Query("SELECT * FROM psxiangmu")
    suspend fun getXmList(): List<PsXiangmu?>?

    @Query("SELECT * FROM psxiangmu where xiangmuId=:id")
    suspend fun getXmListbyId(id:Long): PsXiangmu?

    @Query("SELECT * FROM psxiangmu where xmmc like '%'||:name||'%'")
    suspend fun getXmListbyname(name:String): List<PsXiangmu?>?

    @Delete
    suspend fun deleteXm(vararg xm:PsXiangmu): Int



    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPsGongcheng(psGongcheng: PsGongcheng):Long
    @Update
    fun updateGc(psGongcheng: PsGongcheng)


    @Query("SELECT * FROM psGongcheng")
    suspend fun getGcList(): List<PsGongcheng?>?

    @Query("SELECT * FROM psGongcheng where gcId=:id")
    suspend fun getGcListByid(id:Long): PsGongcheng?

    @Query("SELECT * FROM psGongcheng where ssxmId=:id")
    suspend fun getGcListBypid(id:Long): List<PsGongcheng?>?

    @Query("SELECT * FROM psGongcheng where gcName like '%'||:name||'%'")
    suspend fun getgcListbyname(name:String): List<PsGongcheng?>?

    @Delete
    suspend fun deleteGc(vararg xm:PsGongcheng): Int





    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPsdl(psdl: PsDaolu):Long

    @Update(onConflict = OnConflictStrategy.REPLACE)
    suspend fun updatePsdl(psdl: PsDaolu)

    @Query("SELECT * FROM psdaolu")
    suspend fun getdlList(): List<PsDaolu?>?
    @Delete
    suspend fun deleteDl(vararg dl:PsDaolu): Int
    @Query("SELECT * FROM psdaolu where daoluId=:id")
    suspend fun getDlbyId(id:Long): PsDaolu?
    @Query("SELECT * FROM psdaolu where roadName like '%'||:name||'%'")
    suspend fun getdlListbyname(name:String): List<PsDaolu?>?


    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPsxq(psXiaoqu: PsXiaoqu):Long
    @Update(onConflict = OnConflictStrategy.REPLACE)
    suspend fun updatePsxq(psXiaoqu: PsXiaoqu)

    @Query("SELECT * FROM psxiaoqu")
    suspend fun getxqList(): List<PsXiaoqu?>?
    @Query("SELECT * FROM psxiaoqu where xiaoquId=:id")
    suspend fun getxqbyId(id:Long): PsXiaoqu?
    @Query("SELECT * FROM psxiaoqu where villageName like '%'||:name||'%'")
    suspend fun getxqListbyname(name:String): List<PsXiaoqu?>?
    @Delete
    suspend fun deleteXq(vararg xq:PsXiaoqu): Int


    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertLoginRes(loginresSt: LoginresSt):Long

    @Query("SELECT * FROM loginress")
    suspend fun getLoginres(): LoginresSt?


    @Query("SELECT * FROM psGongcheng where (:xmname IS NULL OR ssxmName like '%'||:xmname||'%') AND(:gcname IS NULL OR gcName like '%'||:gcname||'%') AND ( gcStatus=:status)AND ( tbStatus=:tbStatus)")
    suspend fun gettbgcList(xmname:String?,gcname:String?,status:String?,tbStatus:Int?): List<PsGongcheng?>?

}